Skip to content

pmirror: Add option --unix-socket #109

Merged
merged 1 commit into from
Dec 16, 2019
Merged

pmirror: Add option --unix-socket #109

merged 1 commit into from
Dec 16, 2019

Conversation

donald
Copy link
Collaborator

@donald donald commented Dec 15, 2019

Currently the sender (master) and the receiver (slave) establish a
separate TCP connection for the file data. This requires that the
master can connect to a random TCP port which the slave creates, which
might not be possible if the systems are separated by a firewall.

We can ask ssh to forward another TCP connection, but we'd need to
define the port number from the master not knowing, which ports are free
on the slave. The port namespace is very limited, so collisions are not
unlikely. To avoid that, we use the ability of ssh to use AF_UNIX
sockets for a forwarded channel. These have a much bigger namespace, so
collisions can be better avoided.

Add a option --unix-socket to use a ssh channel for the data connection.
Use /tmp/pmirror_USER_NNNNN as the default socket name, where USER is
the username (on the master) and NNNNN is a 5 digit random value. This
can be overwritten with --unix-socket-name=PATH. The same name is used
on the master and on the server. The name is removed immediately after
the data channel ist established to reduce the time frame for
collisions.

Unlike the TCP based data channel, the unix-socket based data channel is
forwarded by ssh and so is encrypted.

Usage:

If your systems are seperated by a firewall or you want encryption on
the data channel, add --unix-socket to the pmirror command line.

@pmenzel
Copy link
Contributor

pmenzel commented Dec 16, 2019

immediately

pmirror/pmirror Outdated
@@ -1094,5 +1117,9 @@ if ($slave_mode) {
$>==0 or $slave_user='whatever'; # if we are not root, the local slave will also no be root
}

if ($unix_socket && !defined $unix_socket_name) {
$unix_socket_name=sprintf '/tmp/pmirror_setup_%s_%05d',$ENV{'USER'},int(rand(100000));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should TMPDIR be used?

Currently the sender (master) and the receiver (slave) establish a
separate TCP connection for the file data. This requires that the
master can connect to a random TCP port which the slave creates, which
might not be possible if the systems are separated by a firewall.

We can ask ssh to forward another TCP connection, but we'd need to
define the port number from the master not knowing, which ports are free
on the slave. The port namespace is very limited, so collisions are not
unlikely. To avoid that, we use the ability of ssh to use AF_UNIX
sockets for a forwarded channel. These have a much bigger namespace, so
collisions can be better avoided.

Add a option --unix-socket to use a ssh channel for the data connection.
Use /tmp/pmirror_USER_NNNNN  as the default socket name, where USER is
the username (on the master) and NNNNN is a 5 digit random value. This
can be overwritten with --unix-socket-name=PATH.  The same name is used
on the master and on the server. The name is removed immediately after
the data channel ist established to reduce the time frame for
collisions.

Unlike the TCP based data channel, the unix-socket based data channel is
forwarded by ssh and so is encrypted.

Usage:

If your systems are seperated by a firewall or you want encryption on
the data channel, add --unix-socket to the pmirror command line.
@donald
Copy link
Collaborator Author

donald commented Dec 16, 2019

Thanks. Addressed both comments.

@pmenzel pmenzel merged commit 61b546d into master Dec 16, 2019
Sign in to join this conversation on GitHub.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants